import prompt from '@system.prompt';
import fetch from '@system.fetch';
import router from '@system.router';
export default {
    data: {
        title1: "请输入用户名",
        pass: "请输入密码",
        message: "未注册的手机号验证后自动创建账号",
        enter: "登录",
        Account: "admin",
        Password: "123456",
        result: ""
    },
    accountChange(e) {
        this.Account = e.value
    },
    passwordChange(e) {
        this.Password = e.value
    },
    btnclick() {
        console.info(this.Account)
        console.info(JSON.stringify({"username":this.Account,"password":this.Password}));

        fetch.fetch({
            url: `https://amazingmaker.top:80/login?username=` + this.Account + `&password=` + this.Password,
            method: 'POST',
            responseType:"json",
            success: (response) => {
                console.info("fetch success");
                console.info(JSON.stringify(response.data));
                this.result = JSON.parse(response.data);
                console.info(JSON.stringify(this.result.data));
                if (this.result.data == "True") {
                    console.info("Login Success");
                    router.push({
                        uri: 'pages/index2/index2', //指定要跳转的页面
                    });
                } else {
                    console.info("Login Failed");
                    prompt.showToast({
                        message: "密码错误",
                        duration: 3000,
                    });
                }
            }
        });

    }
}
